#include <ostream>
#include <iostream>
#include <string>
#include "Logger.h"
#include "Config.h"
#include "Dispatcher.h"
#include "Resolver.h"
#include "Server.h"
#include "WorkQueue.h"
#include "FileSystem.h"
#include "main.h"


int main( int argc, char **argv )
{
	if( argc < 2 )
	{
		std::cout<<" Please pass Configuration file path \n";
		return -1;
	}

	std::string ConfigPath = argv[ 1 ];
	ConfigFile cfg( ConfigPath );
	std::cout<<" Configuration file path :" << ConfigPath<<"\n";

	Init( cfg );

 	Dispatcher	dispatcher( params.ReqFile	, *(params.pLOGGER)		, *(params.pERRLOGGER) );
 	Resolver	resolver(	*(params.pLOGGER), *(params.pERRLOGGER) , params.ResFile);
	FileSystem	fileSystem( *(params.pERRLOGGER), *(params.pLOGGER) );
 	WorkQueue	workQueue;

 	Server server( dispatcher, resolver,workQueue, fileSystem ,*( params.pLOGGER ), *( params.pERRLOGGER ) );
 	server.StartServer();

 	while( true )
 	{
 		*(params.pLOGGER)<<"System Still Up !\n";
 		sleep( 1 );
 	}

 	delete params.pLOGGER;
 	delete params.pERRLOGGER;

	return 0;
}
